﻿@using SYJ.Model.Entities;
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <title>@ViewBag.Title</title>
    @*@Styles.Render("~/Content/css")*@
    @*@Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @RenderSection("scripts", required: false)*@
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.11.3.min.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/Scripts/Common.js"></script>
 
    @*<script src="~/Scripts/jquerysession.js"></script>*@
</head>
<body class="layui-layout-body">

    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <div class="layui-logo">SYJ - 后台管理</div>
            <!-- 头部区域（可配合layui已有的水平导航） -->
            @*<ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item"><a href="">控制台</a></li>
                <li class="layui-nav-item"><a href="">商品管理</a></li>
                <li class="layui-nav-item"><a href="">用户</a></li>
                <li class="layui-nav-item">
                    <a href="javascript:;">其它系统</a>
                    <dl class="layui-nav-child">
                        <dd><a href="">邮件管理</a></dd>
                        <dd><a href="">消息管理</a></dd>
                        <dd><a href="">授权管理</a></dd>
                    </dl>
                </li>
            </ul>*@
            <ul class="layui-nav layui-layout-right">

                @{ var user = (SysUser)Session["UserKey"];
                 if (user != null && user.id > 0)
                 {
                    <li class="layui-nav-item">
                        <a href="javascript:;">
                            <img src="@user.avatar" class="layui-nav-img">
                            @user.user_name
                        </a>
                        <dl class="layui-nav-child">
                            <dd><a href="~/user/usermgr/index">基本资料</a></dd>
                            <dd><a href="">安全设置</a></dd>
                        </dl>
                    </li>
                    <li class="layui-nav-item"><a href="~/admin/login/Logout">退了</a></li>
                 }
                }


            </ul>
        </div>

        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test" id="navList">
                    @*@{
    string show = "layui-nav-itemed";
    //全部权限
    var Permission = (List<SysPermission>)Session["HasPermissionsByUserID"];
    if (Permission.Count > 0)
    {
        IEnumerable<SysPermission> plist = Permission.Where(m => m.isMenu != 0);
        if (plist.Count() > 0)
        {
            foreach (SysPermission p in plist)
            {
                <li class="layui-nav-item @show">

                    <a class="" href="javascript:;"><i class="layui-icon"> </i> @p.display_name </a>
                    <dl class="layui-nav-child">
                        @foreach (SysPermission pp in Permission.Where(m => m.parent_id == p.id))
                        {
                            <dd><a href="@pp.url" > @pp.name </a></dd>
                        }
                    </dl>
                </li>
                show = "";
            }

        }

    }
}*@
                   
                  
                </ul>
            </div>
        </div>

        <div class="layui-body">
            <!-- 内容主体区域 -->
            <div style="padding: 15px;"> @RenderBody() </div>
        </div>

        <div class="layui-footer">
            <!-- 底部固定区域 -->
            ©   @ViewBag.SysConfig.copyright   @ViewBag.SysConfig.title   @ViewBag.SysConfig.crod
        </div>
    </div>
    


    <script>
        //JavaScript代码区域
        layui.use(['element','jquery'], function () {
            var element = layui.element;
            var $ = layui.jquery;
                $.ajax({
                    type: "POST",
                    url: "/admin/Default/GetMenu",
                    // data: { },
                    dataType: "json",
                    success: function (data) {
                        var sb = "";
                        var permission = data;
                        var show = "layui-nav-itemed";
                        //全部权限
                        if (permission.length > 0) {
                            for (var i = 0; i < permission.length; i++) {
                                if (permission[i].isMenu > 0) {
                                    var id = permission[i].id;
                                    sb += "  <li class=\"layui-nav-item " + show + "\">";
                                    sb += "    <a class=\"\" href=\"javascript:;\"><i class=\"layui-icon\">" + permission[i].iconCls + " </i> " + permission[i].display_name + " </a>";
                                    sb += "    <dl class=\"layui-nav-child\">";
                                    for (var j = 0; j < permission.length; j++) {
                                        if (permission[j].isMenu == 0) {
                                            if (permission[j].parent_id == id) {
                                                sb += " <dd><a href='" + permission[j].url + "' ><i class=\"layui-icon\">" + permission[j].iconCls + " </i>" + permission[j].name + " </a></dd>";
                                            }
                                        }
                                    }
                                    sb += " </dl>";
                                    sb += "</li>";
                                    show = "";
                                }

                            }
                        }
                        $("#navList").html(sb);
                        element.init();
                    }
                });
        });
        
    </script>
    <script>
        
         
        
 
        </script>
</body>
</html>